//
//  config.h
//  beibei_ios
//
//  Created by hebidu on 16/4/16.
//  Copyright © 2016年 hebidu. All rights reserved.
//


/** 常用宏 配置头文件  */
/** 朱凯 982942570@qq.com */


#ifndef DefineConfig_h
#define DefineConfig_h

#ifdef DEBUG
#define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#define DLog(...)
#endif


/** 用于打印数组，且数组中包含\n等转译符，比如覆写了model的描述方法中都有\n，那么打印多个model的数组时用该方法 */
#define ARRAR_LOG(array) NSLog(@"%@", [array componentsJoinedByString:@",*************\n"])

#pragma mark -- 系统参数 --
#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)


//常用宏定义
#define  APP_SCHEME   [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"]
#define  APP_NAME   [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]
#define  APP_SHORT_VERSION   [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
#define  APP_BUNDLE_VERSION   [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]
#define  APP_VERSION [NSString stringWithFormat:@"%@.%@", APP_SHORT_VERSION,APP_BUNDLE_VERSION]
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)


//接口地址定义
#define BOYE_CLIENT_ID      @"by_ios_jigongbao_client_id"
#define BOYE_CLIENT_SECRET  @"byTestSecret654321"

#define BOYE_BASE_URL @"http://api.jinpu.8raw.com"

/** 接口地址 */
#define BOYE_API_URL          [NSString stringWithFormat:@"%@", BOYE_BASE_URL]

/** 图片查看地址 */
#define BOYE_PICTURE_VIEW_URL(id) [NSString stringWithFormat:@"%@/picture/index?id=%@", BOYE_BASE_URL, id]

/** Web Base URL */
#define BOYE_WEB_BASE_URL       [NSString stringWithFormat:@"http://api.ewelisten.com/web.php/web/"]

// 图片地址
#define BOYE_PICTURE_VIEW_URL(id)       [NSString stringWithFormat:@"%@/picture/index?id=%@", BOYE_BASE_URL, id]
// 头像地址
#define BOYE_AVATAR_URL(uid)            [NSString stringWithFormat:@"http://avatar.jinpu.8raw.com?uid=%@", uid]

//--------------------整体色调-------------------------
#define rgba(r,g,b,a)   [UIColor colorWithRed:(r/255.0) green:(g/255.0) blue:(b/255.0) alpha:a]


#define DEFAULT_IMAGE [UIImage imageNamed:@"touxiang"]


//--------------------系统字体-------------------------
#pragma mark -- 系统字体 --
// 字体：细
#define FONT(F) [UIFont systemFontOfSize:F]
// 字体：粗
#define B_FONT(F) [UIFont boldSystemFontOfSize:F]


//--------------------屏幕宽高-------------------------
#pragma mark -- 屏幕宽高 --
// 屏幕 宽度、高度
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT (([UIScreen mainScreen].bounds.size.height) - (Device_Is_iPhoneX? 34 : 0))
#define STATUS_NAV    ([[UIApplication sharedApplication] statusBarFrame].size.height + self.navigationController.navigationBar.frame.size.height)

//----------------------web页-----------------
#define WEB_APP_URL  @"http://www.moodwo.com/index.php/Webview"
#define WEB_PUB_URL  @"http://www.moodwo.com/Public/html"


// 常用
#define BY_USER [ByCacheUser getUserInfo]
#define BY_CONFIG ByNetConfig
#define BY_APPDELEGATE ((AppDelegate *)[UIApplication sharedApplication].delegate)


#define SetChineseAndEnglish(C,E)  (![[[NSUserDefaults standardUserDefaults] objectForKey:@"IsEnglishLanguage"] boolValue] ?  C : E)

#define Device_Is_iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)

#define LineHeight    35

#define adjustsScrollViewInsets_NO(scrollView,vc)\
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
if ([UIScrollView instancesRespondToSelector:NSSelectorFromString(@"setContentInsetAdjustmentBehavior:")]) {\
[scrollView   performSelector:NSSelectorFromString(@"setContentInsetAdjustmentBehavior:") withObject:@(2)];\
} else {\
vc.automaticallyAdjustsScrollViewInsets = NO;\
}\
_Pragma("clang diagnostic pop") \
} while (0)

#endif /* DefineConfig_h */
